/*
 * Copyright (c) 2019.
 * Project: report
 * File : ReportApplication
 * Author: Jimmy Chou
 * Mail: zhou.guangjie123@ztesoft.com
 * Date: 2019-03-30 09:19:43
 */

package com.zjh;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.servlet.MultipartConfigElement;
import javax.sql.DataSource;

/**
 * Created by Jimmy Chou on 2019-03-30 09:19:42
 */
@SpringBootApplication
@EnableTransactionManagement
@MapperScan(basePackages = {"com.zjh.**.dao.**"})
public class ReportApplication extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(ReportApplication.class, args);

    }

    @Bean
    public PlatformTransactionManager txManager(DataSource dataSource) {
        return new DataSourceTransactionManager(dataSource);
    }


    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(ReportApplication.class);
    }

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //单个文件最大 //KB,MB
        factory.setMaxFileSize("10240KB");
        /// 设置总上传数据总大小
        factory.setMaxRequestSize("102400KB");
        return factory.createMultipartConfig();
    }
}
